//
//  FCVehicleIolAndCurveDakePickerView.m
//  ZhuKuang
//
//  Created by mafy on 17/7/12.
//  Copyright © 2017年 jjkj. All rights reserved.
//

#import "FCVehicleIolAndCurveDakePickerView.h"

@interface FCVehicleIolAndCurveDakePickerView()

@property (nonatomic, strong) UIDatePicker *datePicker;

@end

@implementation FCVehicleIolAndCurveDakePickerView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
      
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        
        [self createSubViews];
    }
    
    return self;
}

#pragma mark - 确定按钮监听
- (void)commitButtonClick:(UIButton *)sender{
    
    NSString *str = [CommClass formatTimeStamp:_datePicker.date timeFormat:@"HH:mm"];
    NSLog(@"%@",str);
    
    if (_timeWithHMCompletionHandle) {
        
        _timeWithHMCompletionHandle(str, self.tag);
    }
    
    [self setHidden:YES];
}

#pragma mark - 取消按钮监听
- (void)cancelButtonClick:(UIButton *)sender{
    
    [self setHidden:YES];
}

#pragma mark - 创建视图
- (void)createSubViews{
    
    UIView *backView = [[UIView alloc]init];
    backView.frame = CGRectMake(0, kScreenHeight-300, kScreenWidth, 300);
    backView.backgroundColor = [UIColor whiteColor];
    [self addSubview:backView];
    
    //取消按钮
    UIButton *cancelBtn = [[UIButton alloc]init];
    cancelBtn.frame = CGRectMake(10, 10, 90, 35);
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [cancelBtn setTitleColor:COLOR(51, 51, 51, 1) forState:UIControlStateNormal];
    cancelBtn.titleLabel.font = [UIFont systemFontOfSize:18.0f];
    cancelBtn.layer.cornerRadius = 4.0f;
    cancelBtn.layer.masksToBounds = YES;
    cancelBtn.layer.borderWidth = 0.5f;
    cancelBtn.layer.borderColor = COLOR(121, 121, 121, 1).CGColor;
    [cancelBtn addTarget:self action:@selector(cancelButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [backView addSubview:cancelBtn];
    
    //确定按钮
    UIButton *commitBtn = [[UIButton alloc]init];
    commitBtn.frame = CGRectMake(kScreenWidth-100, 10, 90, 35);
    [commitBtn setTitle:@"确定" forState:UIControlStateNormal];
    [commitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [commitBtn setBackgroundColor:COLOR(22, 155, 213, 1)];
    cancelBtn.titleLabel.font = [UIFont systemFontOfSize:18.0f];
    commitBtn.layer.cornerRadius = 4.0f;
    commitBtn.layer.masksToBounds = YES;
    [commitBtn addTarget:self action:@selector(commitButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [backView addSubview:commitBtn];
    
    //占位符
    UIView *separatorView = [[UIView alloc]init];
    separatorView.backgroundColor = [UIColor grayColor];
    separatorView.frame = CGRectMake(0, CGRectGetMaxY(cancelBtn.frame)+10, kScreenWidth, 0.5);
    [backView addSubview:separatorView];
    
    _datePicker = [[UIDatePicker alloc]init];
    _datePicker.frame = CGRectMake(0, CGRectGetMaxY(cancelBtn.frame), kScreenWidth, 300-55);
    _datePicker.locale = [[NSLocale alloc]initWithLocaleIdentifier:@"zh_ch"];
    _datePicker.datePickerMode = UIDatePickerModeTime;
    [backView addSubview:_datePicker];
}


@end
